package net.cyue.android;

import android.util.Log;
import android.webkit.ConsoleMessage;
import android.webkit.JsPromptResult;
import android.webkit.WebChromeClient;
import android.webkit.WebView;

import com.wragony.android.jsbridge.JsBridge;

public class MyWebChromeClient extends WebChromeClient
{
    public final JsBridge jsBridge;

    public MyWebChromeClient(JsBridge jsBridge)
    {
        super();
        this.jsBridge = jsBridge;
    }


    @Override
    public boolean onJsPrompt(WebView view, String url, String message, String defaultValue, JsPromptResult result) {
        if (this.jsBridge.callJsPrompt(message, result)) {
            return true;
        }
        return super.onJsPrompt(view, url, message, defaultValue, result);
    }

    @Override
    public boolean onConsoleMessage(ConsoleMessage consoleMessage) {
        Log.d(JsBridge.TAG, consoleMessage.message());
        return true;
    }
}




